package com.example.test;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * TODO: 这里要写注释的!
 */
public class ExecutePoolTask implements Runnable {
    private Date date;
    private String name;
    public ExecutePoolTask(String name){
        this.date= new Date();
        this.name= name;
    }

    @Override public void run() {
        System.out.printf("%s: Task %s start on: %s", Thread.currentThread().getName(),name, new Date());
        Long duration= (long)(Math.random()*10);
        System.out.printf("%s： Task %s: Doing a task during %d seconds\n", Thread.currentThread().getName(),name,duration);
        try {
            TimeUnit.SECONDS.sleep(duration);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.printf("%s： Task %s: finished on: %s \n", Thread.currentThread().getName(),name,new Date());

    }
}
